<!DOCTYPE html>
<ui:composition template="/template/layout.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui">

	<f:metadata>
		<f:viewAction action="#{lancamentoController.iniciarDados()}" />
	</f:metadata>
	<ui:define name="titulo">Consulta de lançamentos</ui:define>
	<ui:define name="corpo">
		<h1>Consulta de lançamentos</h1>
		<h:form id="frm">

			<p:dataTable value="#{lancamentoController.lancamentoForm.entidades}" var="lancamento" border="1" cellspacing="0" cellpadding="2" paginator="true" rows="8"
				paginatorPosition="bottom"
				paginatorTemplate=" {CurrentPageReport} {RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
		    currentPageReportTemplate="#{message['label.mostrando']} {startRecord} #{message['label.ate']} {endRecord} #{message['label.de']} {totalRecords} #{message['label.encontrados']}">

				<p:column headerText="Pessoa" sortBy="#{lancamento.pessoa.nome}">
					<h:outputText value="#{lancamento.pessoa.nome}" />
				</p:column>

				<p:column headerText="Descrição" sortBy="#{lancamento.descricao}">
					<h:outputText value="#{lancamento.descricao}" />
				</p:column>

				<p:column headerText="Tipo">
					<h:outputText value="#{lancamento.tipo.descricao}" />
				</p:column>

				<p:column headerText="Valor" style="text-align: right" sortBy="#{lancamento.valor}">
					<h:outputText value="#{lancamento.valor}">
						<f:convertNumber type="currency" locale="pt_BR" />
					</h:outputText>
				</p:column>

				<p:column headerText="Vencimento" style="text-align: center" sortBy="#{lancamento.dataVencimento}">
					<h:outputText value="#{lancamento.dataVencimento}">
						<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
					</h:outputText>
				</p:column>

				<p:column headerText="Pagamento" style="text-align: center" sortBy="#{lancamento.dataPagamento}">
					<h:outputText value="#{lancamento.dataPagamento}">
						<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
					</h:outputText>
				</p:column>

				<p:column headerText="Ações" width="100" style="text-align: center;">
					<p:button icon="ui-icon-pencil" title="Editar" outcome="/paginas/lancamento/cadastroLancamento">
						<f:param name="id" value="#{lancamento.id}" />
					</p:button>

					<p:commandButton icon="ui-icon-trash" title="Excluir" process="@this" update="@form" action="#{lancamentoController.excluir()}">
						<f:setPropertyActionListener value="#{lancamento}" target="#{lancamentoController.lancamentoForm.consulta}" />
					</p:commandButton>

				</p:column>

			</p:dataTable>

		</h:form>
	</ui:define>
</ui:composition>